/*
 * Created on 30.01.2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package ro.qi.framework.sys.entities.components;

import org.w3c.dom.NodeList;

import ro.qi.framework.sys.entities.exception.ComponentException;

/**
 * @author Vlad Lepadatu
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class StringComponent implements EntityComponent {

	protected String value;

	/**
	 * @see ro.qi.framework.entities.components.EntityComponent#verify(java.lang.Object)
	 */
	public void verify(Object _value) throws ComponentException {
		if( !(_value instanceof String) )
			throw new ComponentException(this.getClass().getName() + ": " + value + " is not a String");
	}

	/**
	 * @see ro.qi.framework.entities.components.EntityComponent#setValue(java.lang.Object)
	 */
	public void setValue(Object _value) throws ComponentException {
		if( _value != null ) {
			verify(_value);
			value = (String)_value;
		} else {
			value = "";
		}
	}

	/**
	 * @see ro.qi.framework.entities.components.EntityComponent#getValue()
	 */
	public Object getValue() {
		if( value == null )
			return "";
		return value;
	}

	/**
	 * @see ro.qi.framework.entities.components.EntityComponent#setConfig(org.w3c.dom.NodeList)
	 */
	public void setConfig(NodeList config) {
	}

}
